package com.tsll.service.impl;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.tsll.dao.ExpenditureMapper;
import com.tsll.entity.Expenditure;
import com.tsll.entity.Role;
import com.tsll.entity.Staff;
import com.tsll.service.ExpenditureService;
import com.tsll.vo.Result;
import com.tsll.vo.StaffVo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class ExpenditureServiceImpl implements ExpenditureService {
    @Autowired
    private ExpenditureMapper expenditureMapper;
    @Override
    public Result findAll(Integer current,Integer pageSize, StaffVo staffVo) {
        PageHelper.startPage(current,pageSize);
        List<Expenditure> expenditures = expenditureMapper.selectAll(staffVo);
        PageInfo<Expenditure> pageInfo=new PageInfo<>(expenditures);
        return new Result(200,"查询流水表",pageInfo);
    }

    @Override
    public Result deleteList(Integer id) {
        expenditureMapper.deleteByPrimaryKey(id);
        return new Result(200,"删除成功",null);
    }

    @Override
    public Result insertExpenditure(Expenditure expenditure) {
        int insert = expenditureMapper.insert(expenditure);
        return new Result(200,"添加成功",null);
    }

}
